from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from meiduo_admin.home import home_views
from meiduo_admin.good import sku_views,spu_views,specs_views,spec_options_views,sku_images_views,order_views
from meiduo_admin.admin_user import user_views
from rest_framework_jwt.views import obtain_jwt_token
from meiduo_admin.sysmanager import permission_views,permission_group_views,permission_admin_views

urlpatterns = [
    url(r'^authorizations/$',obtain_jwt_token),
    url(r'^statistical/total_count/$',home_views.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$',home_views.UserDayIncreaseCountView.as_view()),
    url(r'^statistical/day_active/$',home_views.UserDayActiveCountView.as_view()),
    url(r'^statistical/day_orders/$',home_views.UserDayOrdersCountView.as_view()),
    url(r'^statistical/month_increment/$',home_views.UserMonthIncrementCountView.as_view()),
    url(r'^statistical/goods_day_views/$',home_views.GoodCategoryVisitCountView.as_view()),
    url(r'^users/$',user_views.UserListView.as_view()),
    # sku管理
    url(r'^skus/categories/$',sku_views.SKUCategoryView.as_view()),
    url(r'^goods/simple/$', sku_views.SPUListView.as_view()),
    url(r'^goods/(?P<spu_id>\d+)/specs/$', sku_views.SPUSpecificationListView.as_view()),
    # spu管理
    url(r'^goods/brands/simple/$',spu_views.SPUBrandListView.as_view()),
    url(r'^goods/channel/categories/$',spu_views.SPUCategoryListView.as_view()),
    url(r'^goods/channel/categories/(?P<category_id>\d+)/$', spu_views.SubsCategoryListView.as_view()),
    # goods images
    url(r'^goods/images/$',spu_views.SPUDetailImageView.as_view()),
    url(r'^goods/specs/simple/$',spec_options_views.SpecListView.as_view()),
    # 图片添加时展示sku信息
    url(r'^skus/simple/$',sku_images_views.SKUInfoListView.as_view()),
    # orders
    url(r'^orders/$',order_views.OrderInfoView.as_view()),
    # 订单详情
    url(r'^orders/(?P<pk>\d+)/$',order_views.OrderDetailView.as_view()),
    # 订单评价操作
    url(r'^orders/(?P<pk>\d+)/status/$',order_views.OrderStatusView.as_view()),
    # permiss/content_type
    url(r'^permission/content_types/$',permission_views.PermissionContentTypeListView.as_view()),
    # 用户组管理
    url(r'^permission/simple/$', permission_group_views.PermissionSimpleView.as_view()),
    # 管理员管理
    url(r'^permission/groups/simple/$', permission_admin_views.PermissionAdminSimpleView.as_view()),

]

router = DefaultRouter()
router.register('permission/admins',permission_admin_views.PermissionAdminsViewSet,basename='permission_admins')
urlpatterns+=router.urls

router = DefaultRouter()
router.register('permission/groups',permission_group_views.PermissionGroupViewSet,basename='permission_groups')
urlpatterns += router.urls

router = DefaultRouter()
router.register('permission/perms',permission_views.PermissionViewSet,basename='permission')
urlpatterns += router.urls

router = DefaultRouter()
router.register('skus/images',sku_images_views.SKUImagesViewSet,basename='images')
urlpatterns += router.urls

router = DefaultRouter()
router.register('skus',sku_views.SKUViewSet,basename='skus')
urlpatterns += router.urls

router = DefaultRouter()
router.register('goods/specs',specs_views.SpecsViewSet,basename='specs')
urlpatterns += router.urls

router = DefaultRouter()
router.register('goods',spu_views.SPUViewSet,basename='spus')
urlpatterns += router.urls

# specs options
router = DefaultRouter()
router.register('specs/options',spec_options_views.SpecsOptionsViewSet,basename='spec_options')
urlpatterns += router.urls

